<?php
/*
Template Name: Portfolio Page
*/

get_header(); // Loads the header.php template. ?>		
		
		<div id="main" class="page-portfolio clearfix">	
			
					
			<div class="page-center clearfix">	
			
				<section id="options" class="clearfix">
				
					<ul id="portfolio-filter" class="option-set clearfix" data-option-key="filter">
						<li><a href="#filter" data-option-value="*" class="selected"><?php _e('show all', hybrid_get_textdomain()); ?></a></li>
						<?php 
						//$global $page;
						$cats= get_post_meta(get_the_ID(), '_portfolio_category_multicheck', false);						
						$items_amount = get_post_meta(get_the_ID(), '_portfolio_items_amount', true);
						$layout = get_post_meta(get_the_ID(), '_portfolio_layout_select', true);
						
						if(is_array($cats) && count($cats) > 0) {	
							$cats_id_list = '';
							$i = 0;	
							foreach($cats as $key=>$catid){ 								
								$i++;
								if($i == 1)
									$cats_id_list = $catid;
								else
									$cats_id_list .= ',' . $catid;
							}						
					
							foreach((get_categories('include='. $cats_id_list)) as $category) { ?>				
								<li><a class=""  href="#filter" title="" data-option-value=".<?php echo $category->category_nicename;?>"><?php echo $category->cat_name;?></a></li>
							<?php } 
						} ?>				
					</ul>						
				
				</section> <!-- #options -->					
				
				<div id="content-portfolio" class="clearfix">
				<div id="portfolio-list" class="clearfix isotope">
					<?php if(is_array($cats) && count($cats) > 0) {						
					
						$thumb_size = 'thumbnail'; 
						if ($layout=='four-column') {$thumb_size = 'four-column-thumb'; $no_pic = 'pf-no-pic-small.gif'; }
						else if ($layout=='three-column')  {$thumb_size = 'three-column-thumb'; $no_pic = 'pf-no-pic-media.gif'; }
						else if ($layout=='two-column')  {$thumb_size = 'two-column-thumb'; $no_pic = 'pf-no-pic-large.gif';}						
						
						$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;						
						query_posts(array('showposts' => $items_amount, 'category__in' => $cats, 'paged'=>$paged)); 
						
						if(have_posts()) : while (have_posts()) : the_post();  ?>
							<div class="<?php echo $layout;?> <?php foreach((get_the_category()) as $category) echo ' ' . $category->category_nicename;?> hentry"> 
								<?php $bPortfolio = true; include('entry-image.php'); ?>				
								
								<div class="entry-info">
									<?php $type = get_post_meta(get_the_ID(), '_portfolio_posttype_select', true); 
									$type_class = empty($type)? 'post':$type;?>
									<div class="entry-icon <?php echo $type_class;?>"></div>									
									<h3 class="entry-title"><a href="<?php echo esc_url(get_permalink()); ?>"><?php the_title(); ?></a></h3>											
								</div>
							
							</div><!-- .hentry -->	
							
						<?php endwhile; ?>						
						<?php endif; ?>
							
					<?php } ?>	
				</div> <!-- #portfolio-list -->	
				
				<div id="nav-below" class="page_navi">						 
					<?php cv_pagenavi(); ?> 
				</div><!-- #nav-below -->				
				
				<?php wp_reset_query(); 	?>
			
			</div> <!-- #content -->		
			
			</div><!-- .center -->
		</div><!-- #main -->		
	
<?php get_footer(); // Loads the footer.php template. ?>		